﻿@model FunPlus.Application.Marketing.Dto.GetCouponOutput

@{
    ViewBag.Title = "添加优惠券";
}
@section CSS{
    <link href="~/Content/css/layerui/layui.css" rel="stylesheet" />
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            @ViewBag.text
            <small>优惠券</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">营销管理</a></li>
            <li><a href="/Marketing/Coupons">优惠券列表</a></li>
            <li class="active">@ViewBag.text 优惠券</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <div class="ibox float-e-margins">

                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    <form class="form-horizontal" id="from-add" novalidate="novalidate" method="post" action="/Marketing/Coupon">
                                        @Html.AntiForgeryToken()
                                        @Html.HiddenFor(model => model.coupon_id)

                                        <div class="form-horizontal">
                                            <div class="form-group">
                                                @Html.LabelFor(model => model.coupon_name, htmlAttributes: new { @class = "control-label col-md-2" })
                                                <div class="col-md-10">
                                                    @Html.EditorFor(model => model.coupon_name, new { htmlAttributes = new { @class = "form-control" } })
                                                    @Html.ValidationMessageFor(model => model.coupon_name, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                @Html.LabelFor(model => model.description, htmlAttributes: new { @class = "control-label col-md-2" })
                                                <div class="col-md-10">
                                                    @Html.EditorFor(model => model.description, new { htmlAttributes = new { @class = "form-control" } })
                                                    @Html.ValidationMessageFor(model => model.description, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                @Html.LabelFor(model => model.remark, htmlAttributes: new { @class = "control-label col-md-2" })
                                                <div class="col-md-10">
                                                    @Html.EditorFor(model => model.remark, new { htmlAttributes = new { @class = "form-control" } })
                                                    @Html.ValidationMessageFor(model => model.remark, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="control-label col-md-2">优惠券面值</label>
                                                <div id="couponValue" style="display:none">
                                                    <div>
                                                        <label class="control-label col-md-2" style="padding-top:10px"></label>
                                                        <div class="col-md-10" style="padding-top:10px">
                                                            <div class="col-md-3" style="padding-left:0px">
                                                                <input type="text" class="form-control" id="value" name="value" placeholder="面值" />
                                                            </div>
                                                            <div class="col-md-3">
                                                                <input type="text" class="form-control" id="total_quantity" name="total_quantity" placeholder="发行量" />
                                                            </div>
                                                            <div class="col-md-3">
                                                                <input type="text" class="form-control" id="amount" name="amount" placeholder="限制使用额度" />
                                                            </div>
                                                            <div class="col-md-3">
                                                                <button class="btn btn-danger" onclick="DeleteDiv(this)" type="button">-删除面值</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-md-10">
                                                    <div class="col-md-3" style="padding-left:0px">
                                                        <input type="text" class="form-control" id="value" name="value" placeholder="面值" />
                                                    </div>
                                                    <div class="col-md-3">
                                                        <input type="text" class="form-control" id="total_quantity" name="total_quantity" placeholder="发行量" />
                                                    </div>
                                                    <div class="col-md-3">
                                                        <input type="text" class="form-control" id="amount" name="amount" placeholder="限制使用额度" />
                                                    </div>
                                                    <div class="col-md-3">
                                                        <button class="btn btn-primary" onclick="AddDiv()" type="button">+增加面值</button>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="control-label col-md-2">有效期</label>
                                                <div class="col-md-10">
                                                    <div class="col-md-5" style="padding-left:0px">
                                                        <input type="text" class="form-control" id="start_date" name="start_date" placeholder="开始时间" />
                                                    </div>
                                                    <div class="col-md-1" style="padding:5px; width:40px">
                                                        <label class="form-label">至</label>
                                                    </div>
                                                    <div class="col-md-5" style="padding-left:0px">
                                                        <input type="text" class="form-control" id="end_date" name="end_date" placeholder="结束时间" />
                                                    </div>
                                                    @Html.ValidationMessageFor(model => model.start_date, "", new { @class = "text-danger" })
                                                    @Html.ValidationMessageFor(model => model.end_date, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="control-label col-md-2">适用商品</label>
                                                <div class="col-md-10">
                                                    <button class="btn btn-primary" type="button">添加商品</button>
                                                    @Html.ValidationMessageFor(model => model.coupon_type, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                @Html.LabelFor(model => model.coupon_type, htmlAttributes: new { @class = "control-label col-md-2" })
                                                <div class="col-md-10">
                                                    <select class="form-control" id="coupon_type" name="coupon_type">
                                                        <option value="0">不限制</option>
                                                        <option value="1">普通券</option>
                                                        <option value="2">会员券</option>
                                                    </select>
                                                    @Html.ValidationMessageFor(model => model.coupon_type, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                @Html.LabelFor(model => model.status, htmlAttributes: new { @class = "control-label col-md-2" })
                                                <div class="col-md-10">
                                                    <select class="form-control" id="status" name="status">
                                                        <option value="1">启用</option>
                                                        <option value="0">禁用</option>
                                                    </select>
                                                    @Html.ValidationMessageFor(model => model.status, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <div class="col-sm-4 col-sm-offset-3">
                                                    <button class="btn btn-primary" type="submit">保存信息</button>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

</div>

@section JS{
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Content/plugins/validate/messages_zh.min.js"></script>
    <script type="text/javascript">

        $(function () {
            $("#status").val(@Model.status);
            $("#coupon_type").val(@Model.coupon_type);
        });

        $('#start_date').datepicker({
            autoclose: true
        });

        $('#end_date').datepicker({
            autoclose: true
        });

        function AddDiv(object) {
            var couponValue = $('#couponValue').parent();
            var couponValueClone = $('#couponValue').html();
            couponValue.append(couponValueClone);
        }

        function DeleteDiv(object) {
            $(object).parent().parent().parent().remove();
        }

    </script>
}